<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        /**
         * race  竞赛
         * let res = Promise.race([p1,p2,p3])
         * 谁先回来，res的状态和结果值就跟谁一致
         */
        let p1 = new Promise((resolve, reject)=>{
            setTimeout(()=>{
                resolve('p1');
            },1000);
        })
        let p2 = new Promise((resolve, reject)=>{
            setTimeout(()=>{
                reject('p2')
            },1500)
        })
        let p3 = new Promise((resolve, reject)=>{
            setTimeout(()=>{
                reject('p3')
            },2500);
        });
        let res = Promise.race([p1,p2,p3]);
        console.log(res);
    </script>
</body>

</html>